package org.aurora.core.server.scheduler.task;

import org.aurora.core.server.expression.cron.CronExpression;
import org.aurora.model.entity.Task;
import org.aurora.model.type.TaskType;

public class TaskWrapperFactory {
    public static TaskWrapper createScheduleTask(Task task) {
        int type = task.getType();

        TaskType taskType = TaskType.getByCode(type);

        switch (taskType) {
            case CRON: {
                try {
                    CronExpression cronExpression = new CronExpression(task.getExpression());
                    return new TaskWrapper(task, cronExpression);
                } catch (Exception ignore) {
                }
            }
            case FIXED_RATE: {
                return null;
            }
            case FIXED_DELAY: {
                return null;
            }
            default: {
                return null;
            }
        }
    }

}
